package com.example.design.pattern.structure

/**
 * 适配器模式，充当转换角色，起到兼容作用，提高组件复用性
 *适配器模式分对象适配器和类适配器
 **/
interface TriplePin {
    fun electrify(l: Int, r: Int, m: Int)
}

interface DualPin {
    fun electrify(l: Int, r: Int)
}

open class Tv : DualPin {
    override fun electrify(l: Int, r: Int) {

    }

}

fun main() {
    TvAdapter().electrify(1, 1, -1)
    Adapter(Tv()).electrify(1, 1, -1)

}

//类适配器
class TvAdapter : Tv(), TriplePin {
    override fun electrify(l: Int, r: Int, m: Int) {
        super.electrify(l, r)
    }

}

//对象适配器
class Adapter(private val dualPin: DualPin) : TriplePin {

    override fun electrify(l: Int, r: Int, m: Int) {
        dualPin.electrify(l, r)
    }

}